#include "ftp_group.h"
#include "auth_exception.h"

#include "ftp_user.h"

AUTH_NS_START

FtpGroup::FtpGroup(std::string groupName, gid_t gid)
	:m_sGroupName(groupName), m_sGid(gid), m_UserList() {
}

FtpGroup::~FtpGroup() {
	this->m_UserList.clear();
}

void FtpGroup::RegisterUserInGroup(FtpUser* user) {
	uid_t sid = user->GetSid();
	this->m_UserList[sid] = user->GetUserName();
	user->RegisterGroupToUser(this);
}

bool FtpGroup::IsUserMember(const FtpUser& user) {
	UserListType::iterator pos = m_UserList.find(user.GetSid());

	bool found = (pos != m_UserList.end());
	return found;
}

AUTH_NS_END
